package com.ad.pet.app.account.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ad.pet.R;
import com.ad.pet.common.data.utils.glide.GlideUtil;
import com.ad.pet.models.remote.account.order.OrderType;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**我的预约item
 * Created by SEELE on 2019/2/15.
 */

public class OrderTypeAdapter extends BaseQuickAdapter<OrderType, BaseViewHolder> {

    private OnItemGoodClickLinstener mOnItemClickLinstener;


    public OrderTypeAdapter(@Nullable List<OrderType> data) {
        super(R.layout.item_order_status_layout, data);

    }

    public void setOnItemGoodClickLinstener(OnItemGoodClickLinstener onItemClickLinstener) {
        mOnItemClickLinstener = onItemClickLinstener;
    }

    @Override
    protected void convert(final BaseViewHolder helper, final OrderType item) {
        TextView tv_time = helper.getView(R.id.tv_time);
        TextView tv_status = helper.getView(R.id.tv_status);
        TextView tv_confirm = helper.getView(R.id.tv_confirm);

        TextView tvPrice = helper.getView(R.id.tvTitle);
        ImageView ibHead = helper.getView(R.id.iv_head);
        TextView tvTitle =helper.getView(R.id.tv_price);
        TextView tv_count = helper.getView(R.id.tv_count);
//        TextView tvNumber = helper.getView(R.id.tv_number);
        GlideUtil.load(mContext,item.getPic_cover_small(),ibHead);
        tvTitle.setText("预约时间 "+item.getAppoint_offservice_date()+" "+item.getAppoint_offservice_time());
        tvPrice.setText(item.getOffservice_name());
//        tvNumber.setText("x"+item.getNum());
        if ("2".equals(item.getAppoint_status())||"9".equals(item.getAppoint_status())) {
            helper.getView(R.id.relativeLayout_reduce).setVisibility(View.GONE);
        } else {
            helper.getView(R.id.relativeLayout_reduce).setVisibility(View.VISIBLE);
        }
//        tv_count.setText("合计:"+item.getGoods_money());
        tv_status.setText("2".equals(item.getAppoint_status())?"已完成":"9".equals(item.getAppoint_status())?"已取消":"已预约");
        tv_time.setText(item.getCreate_date());

        tv_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnItemClickLinstener.onCancel(helper.getLayoutPosition());
            }
        });


    }


    public interface OnItemGoodClickLinstener {


        void onCancel(int position);



    }

}
